package org.liuhy.utils
{
	import mx.collections.ArrayCollection;
	
	import org.liuhy.line.AbstractLine;
//	import org.liuhy.line.ULine;
	import org.liuhy.node.FlowNode;
	public class FlowNodeUtils
	{
		public static function getFlowNodeById(p_id:String,p_flowNodeList:ArrayCollection):FlowNode{
			for(var i:int=0;i<p_flowNodeList.length;i++){
				var _flowNode:FlowNode = p_flowNodeList.getItemAt(i) as FlowNode;
				if(p_id==_flowNode.flowNodeId) return p_flowNodeList.getItemAt(i) as FlowNode;
			}
			return null;
		}
		public static function getFlowNodeByName(p_Name:String,p_flowNodeList:ArrayCollection):FlowNode{
			for(var i:int=0;i<p_flowNodeList.length;i++){
				var _flowNode:FlowNode = p_flowNodeList.getItemAt(i) as FlowNode;
				if(p_Name==_flowNode.title) return p_flowNodeList.getItemAt(i) as FlowNode;
			}
			return null;
		}
		//断开流程节点与箭头关联关系;
		public static function disconnectArrow(p_uLine:AbstractLine):void{
			if(null!=p_uLine.in_flowFocusNode){
				var _flowNode:FlowNode = p_uLine.in_flowFocusNode.parent as FlowNode;
				_flowNode.removeInLine(p_uLine);
				p_uLine.in_flowFocusNode = null;
			}
		}
		//断开流程节点与开始线关联关系;
		public static function disconnectFrom(p_uLine:AbstractLine):void{
			if(null!=p_uLine.out_flowFocusNode){
				var _flowNode:FlowNode = p_uLine.out_flowFocusNode.parent as FlowNode;
				_flowNode.removeOutLine(p_uLine);
				p_uLine.out_flowFocusNode = null;
			}
		}
	}
}